package cn.action;

import cn.entity.master.Fighter;
import cn.entity.utils.Paint;
import cn.entity.StartView;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;

public class StartAction  {
    private JLabel title;
    private JButton start;
    private JButton exit;
    private JLabel back;
    private Frame frame;
    private JButton teach;
    private CollideAction collideAction;
    public StartAction(StartView startView) {
        frame=startView.getFrame();
        title=startView.getTitleLabel();
        start=startView.getStartButton();
        exit=startView.getExitButton();
        back=startView.getBackgroundLabel();
        teach=startView.getTeach();

    }
    public void action(Fighter fighter)  {
        try {
            title.setVisible(false);
            start.setVisible(false);
            exit.setVisible(false);
            back.setVisible(false);
            teach.setVisible(false);
            collideAction=new CollideAction(fighter.getX(),fighter.getY(),fighter.getWidth(),fighter.getHeight());
            frame.add(new Paint(fighter,frame,collideAction,this));
        }catch(IOException e){
            e.printStackTrace();
        }
    }
    public void reBack(){
        title.setVisible(true);
        start.setVisible(true);
        exit.setVisible(true);
        back.setVisible(true);
        teach.setVisible(true);
    }
}
